home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The 640 MEG Shareware Studio 2
/
The 640 Meg Shareware Studio CD-ROM Volume II (Data Express)(1993).ISO
/
basic
/
imb9107.zip
/
ISAMREPT.BAS
< prev
next >
Wrap
BASIC Source File
|
1991-07-12
|
8KB
|
143 lines
DEFINT A-Z
'PROGRAM - ISAMREPT.BAS
'**********************************************************************
'** Purpose - This program creates an invoice report from **
'** multiple tables in multiple ISAM databases **
'**********************************************************************
'Initialize -----------------------------------------------------------
'$INCLUDE: 'ISAM.BI'
CONST True = -1, False = 0
' WIDTH ,43 'Uncomment this line if you have an EGA/VGA monitor
' to see the complete display on screen at one time
HdgA$ = " Part# Description Price Number Amount"
FmtA$ = " \ \ \ \ "
FmtB$ = "###.## ### ###.##"
DIM Cust AS CustomerRec
DIM IH AS InvoiceHeaderRec
DIM IL AS InvoiceLineItemRec
DIM Inven AS InventoryRec
CLS : PRINT "..ISAM Sample report from mulitiple tables"
' ===== Open tables and set the indexes ===============================
CustTbl = 1: IHTbl = 2: ILTbl = 3: InvenTbl = 4
OPEN "AR.MDB" FOR ISAM CustomerRec "CustTbl" AS CustTbl
OPEN "AR.MDB" FOR ISAM InvoiceHeaderRec "InvHdrTbl" AS IHTbl
OPEN "AR.MDB" FOR ISAM InvoiceLineItemRec "InvLineItemTbl" AS ILTbl
OPEN "INVEN.MDB" FOR ISAM InventoryRec "InvenTbl" AS InvenTbl
SETINDEX CustTbl, "ByCustNbr"
SETINDEX IHTbl, "ByCustNbr"
SETINDEX ILTbl, "ByInvNbr"
SETINDEX InvenTbl, "ByInvenNbr"
'***************** M A I N P R O G R A M L O O P ******************
'*
LastCustNbr$ = "" 'Initialize signal value '*
MOVEFIRST IHTbl 'Set position to first invoice '*
WHILE NOT EOF(IHTbl) 'Process in Customer#/Invoice# '*
' order '*
RETRIEVE IHTbl, IH '*
IF LastCustNbr$ <> IH.CustNbr THEN 'New Customer '*
GOSUB GetNewCustomer '*
GOSUB PrintCustomerHdg '*
LastCustNbr$ = Cust.CustNbr 'Reset customer # signal value '*
END IF '*
GOSUB PrintInvoiceHdr '*
GOSUB PrintInvoiceLineItems '*
MOVENEXT IHTbl '*
'*
WEND '*
CLOSE CustTbl, IHTbl, ILTbl, InvenTbl '*
END '*
'*
'**********************************************************************
GetNewCustomer: '------------------------------------------------------
'=
SEEKEQ CustTbl, IH.CustNbr 'Lookup customer name '=
'=
IF NOT EOF(1) THEN 'If customer ID found '=
RETRIEVE CustTbl, Cust '=
ELSE ' otherwise ID not found '=
Cust.CustNbr = IH.CustNbr '=
Cust.CompName = "Not listed in customer file" '=
END IF '=
RETURN '=
'=
'======================================================================
PrintCustomerHdg: '----------------------------------------------------
'=
PRINT : PRINT STRING$(70, "="): PRINT '=
PRINT " CustNbr: "; Cust.CustNbr; TAB(30); '=
PRINT " Name: "; Cust.CompName '=
RETURN '=
'=
'======================================================================
PrintInvoiceHdr: '-----------------------------------------------------
'=
PRINT : PRINT USING " Invoice: #####"; IH.InvNbr '=
PRINT HdgA$ '=
RETURN '=
'=
'======================================================================
PrintInvoiceLineItems: '-----------------------------------------------
'=
Done = False '=
SEEKGE ILTbl, IH.InvNbr 'Find 1st line item if it exists '=
WHILE NOT (Done OR EOF(ILTbl)) '=
RETRIEVE ILTbl, IL '=
IF IL.InvNbr = IH.InvNbr THEN 'Make sure line item matches inv# '=
GOSUB LookupInventoryItem '=
GOSUB PrintLineItem '=
MOVENEXT ILTbl '=
ELSE 'Line item does not belong to inv '=
Done = True 'Done with inv or no line items for inv number '=
END IF '=
WEND '=
RETURN '=
'=
'======================================================================
LookupInventoryItem: '-------------------------------------------------
'=
SEEKEQ InvenTbl, IL.InvenNbr 'Look up inventory information '=
IF EOF(InvenTbl) THEN '=
Inven.Desc = "Item #" + IL.InvenNbr + " not listed" '=
ELSE '=
RETRIEVE InvenTbl, Inven '=
END IF '=
RETURN '=
'=
'======================================================================
PrintLineItem: '-------------------------------------------------------
'=
ExtendedAmount@ = IL.PriceEach * IL.NbrSold '=
PRINT USING FmtA$; IL.InvenNbr; Inven.Desc; '=
PRINT USING FmtB$; IL.PriceEach; IL.NbrSold; ExtendedAmount@ '=
RETURN '=
'=
'======================================================================